package com.leetcode.bit;

import java.util.Arrays;

/**
 * @author Dennis Li
 * @date 2020/7/22 11:01
 */
public class SingleNumber2_offer_56 {

    public int singleNumber(int[] nums) {
        Arrays.sort(nums);
        int sum = nums[0];
        for (int i = 1; i < nums.length; i++) {
            sum ^= nums[i];
            if (nums[i] == nums[i - 1]) i++;
        }
        return sum;
    }

}
